package com.yixin.publisher.configure;

import com.yixin.publisher.Listener;
import org.springframework.amqp.core.AcknowledgeMode;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfit {



    @Bean
    public SimpleMessageListenerContainer rabbitListener(ConnectionFactory connectionFactory
            , Listener listener) {
        SimpleMessageListenerContainer factory = new SimpleMessageListenerContainer(connectionFactory);
        factory.setQueues(new Queue("simple.queue"));
        factory.setExposeListenerChannel(true);
        factory.setConcurrentConsumers(100);
        factory.setMaxConcurrentConsumers(100);
        factory.setAcknowledgeMode(AcknowledgeMode.MANUAL);
        factory.setMessageListener(listener);
        factory.setPrefetchCount(100);
        return factory;
    }
}
